//
//  SDSKTagView.m
//  SuperDoctor
//
//  Created by 年浩杰 on 16/7/9.
//  Copyright © 2016年 SD. All rights reserved.
//

#import "SDSKTagView.h"

@interface SDSKTagView ()
//美容颜
@property (nonatomic,strong) UIButton *beautiful;
//肉肉帮
@property (nonatomic,strong) UIButton *meat;
//化妆控
@property (nonatomic,strong) UIButton *makeup;
//cosplay
@property (nonatomic,strong) UIButton *cosplay;
@end

@implementation SDSKTagView

- (instancetype)init {
    
    if (self = [super init]) {
        
        [self setupUI];
    }
    return self;
}
//初始化控件
- (void) setupUI {
    
    self.beautiful= [[UIButton alloc] init];
    
    [self setClickButton:self.beautiful title:@"美容颜"];
    
    [self addSubview:self.beautiful];
    
    
    self.meat = [[UIButton alloc] init];
    
    [self setClickButton:self.meat title:@"肉肉帮"];
    
    [self addSubview:self.meat];
    
    
    self.makeup = [[UIButton alloc] init];
    
    [self setClickButton:self.makeup title:@"化妆控"];
    
    [self addSubview:self.makeup];
    
    
    self.cosplay = [[UIButton alloc] init];
    
    [self setClickButton:self.cosplay title:@"角色扮演"];
    
    [self addSubview:self.cosplay];
    
}

- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    [self.beautiful mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self).offset(10);
        make.left.equalTo(self).offset(30);
        make.height.offset(40);
    }];
    
    [self.meat mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self.beautiful);
        make.left.equalTo(self.beautiful.mas_right).offset(30);
        make.right.equalTo(self).offset(-30);
        make.height.width.equalTo(self.beautiful);

    }];
    
    [self.makeup mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.beautiful.mas_bottom).offset(10);
        make.leading.mas_equalTo(self.beautiful.mas_leading);
         make.trailing.mas_equalTo(self.beautiful.mas_trailing);
        make.height.mas_equalTo(self.beautiful);
        make.centerX.equalTo(self.beautiful.mas_centerX);
        
        
        
    }];
    
    [self.cosplay mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.makeup);
        make.leading.mas_equalTo(self.meat.mas_leading);
        make.trailing.mas_equalTo(self.meat.mas_trailing);
        make.height.mas_equalTo(self.beautiful);
        
    }];

    
}

- (void)setClickButton:(UIButton *)button title:(NSString *)titlt {
    
    //字体大小
    button.titleLabel.font = FONT(18);
    //文字
    [button setTitle:
              titlt forState:UIControlStateNormal];
    //文字颜色
    [button setTitleColor:[UIColor colorWithRed:arc4random_uniform(255)/256.0 green:arc4random_uniform(255)/256.0 blue:arc4random_uniform(255)/256.0 alpha:1] forState:UIControlStateNormal];
    //边框宽度
    button.layer.borderWidth = 1.0f;
    //边框颜色
    button.layer.borderColor = [[UIColor colorWithRed:arc4random_uniform(255)/256.0 green:arc4random_uniform(255)/256.0 blue:arc4random_uniform(255)/256.0 alpha:1]CGColor];
    //边框半径
    button.layer.cornerRadius = 5;
    
    
}
@end
